/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "project_resource")
@NamedQueries({
    @NamedQuery(name = "ProjectResource.findAll", query = "SELECT p FROM ProjectResource p"),
    @NamedQuery(name = "ProjectResource.findByPrId", query = "SELECT p FROM ProjectResource p WHERE p.prId = :prId"),
    @NamedQuery(name = "ProjectResource.findByPrNumber", query = "SELECT p FROM ProjectResource p WHERE p.prNumber = :prNumber")})
public class ProjectResource implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "pr_id")
    private Integer prId;
    @Basic(optional = false)
    @Column(name = "pr_number")
    private long prNumber;
    @JoinColumn(name = "res_id", referencedColumnName = "res_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Resource resource;
    @JoinColumn(name = "project_id", referencedColumnName = "p_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Project project;

    public ProjectResource() {
    }

    public ProjectResource(Integer prId) {
        this.prId = prId;
    }

    public ProjectResource(Integer prId, long prNumber) {
        this.prId = prId;
        this.prNumber = prNumber;
    }

    public Integer getPrId() {
        return prId;
    }

    public void setPrId(Integer prId) {
        this.prId = prId;
    }

    public long getPrNumber() {
        return prNumber;
    }

    public void setPrNumber(long prNumber) {
        this.prNumber = prNumber;
    }

    public Resource getResource() {
        return resource;
    }

    public void setResource(Resource resource) {
        this.resource = resource;
    }

    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prId != null ? prId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProjectResource)) {
            return false;
        }
        ProjectResource other = (ProjectResource) object;
        if ((this.prId == null && other.prId != null) || (this.prId != null && !this.prId.equals(other.prId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.ProjectResource[prId=" + prId + "]";
    }

}
